package cn.zwt.wolf.domain.base;

import javax.persistence.*;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

@MappedSuperclass
@Inheritance(strategy = InheritanceType.JOINED)
public class BaseDomain implements Serializable {

	public static final int STATUS_DELETED = -1;

	public static final int STATUS_NORMAL = 1;

	public static final int STATUS_UNABLE = 0;

	public static final int STATUS_SYSTEM_UNABLE = 2;

	public static final int STATUS_BE_MERGED = 3;

	public static final int STATUS_UNKNOW = 999;

	public static final int PARENTID_ZERO = 0;

	public static final int DEFAULT_VALUE = 0;

	@Column(name = "code")
	private String code;
	@Column(name = "status")
	private int status = 1;
	@Column(name = "operator_id")
	private int operatorId = 0;
	@Column(name = "valid_time")
	private Date validTime;
	@Column(name = "invalid_time")
	private Date invalidTime;
	@Column(name = "update_time")
	private Date updateTime;
	@Column(name = "create_time")
	private Date createTime;

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getOperatorId() {
		return operatorId;
	}

	public void setOperatorId(int operatorId) {
		this.operatorId = operatorId;
	}

	public Date getValidTime() {
		return validTime;
	}

	public void setValidTime(Date validTime) {
		this.validTime = validTime;
	}

	public Date getInvalidTime() {
		return invalidTime;
	}

	public void setInvalidTime(Date invalidTime) {
		this.invalidTime = invalidTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	
	@Transient
	public String getValidTimeStr() {
		if (validTime != null) {
			return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(validTime);
		}
		return "";
	}

	@Transient
	public String getInvalidTimeStr() {
		if (invalidTime != null) {
			return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(invalidTime);
		}
		return "";
	}

	@Transient
	public String getUpdateTimeStr() {
		if (updateTime != null) {
			return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(updateTime);
		}
		return "";
	}

	@Transient
	public String getCreateTimeStr() {
		if (createTime != null) {
			return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTime);
		}
		return "";
	}
	
}
